home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Utils / Forecastfox / Bin / forecastfox-0.8.5.1-fx+mz+ns.xpi / install.js next >
Encoding:
Text File  |  2006-02-18  |  4.3 KB  |  97 lines

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3.  *
  4.  * The contents of this file are subject to the Mozilla Public License Version
  5.  * 1.1 (the "License"); you may not use this file except in compliance with
  6.  * the License. You may obtain a copy of the License at
  7.  * http://www.mozilla.org/MPL/
  8.  *
  9.  * Software distributed under the License is distributed on an "AS IS" basis,
  10.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11.  * for the specific language governing rights and limitations under the
  12.  * License.
  13.  *
  14.  * The Original Code is Forecastfox.
  15.  *
  16.  * The Initial Developer of the Original Code is
  17.  * Jon Stritar <jstritar@MIT.EDU>.
  18.  * Portions created by the Initial Developer are Copyright (C) 2005
  19.  * the Initial Developer. All Rights Reserved.
  20.  *
  21.  * Contributor(s):
  22.  * Jon Stritar <jstritar@MIT.EDU>
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  26.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. // package constants
  39. const DISPLAY_NAME   = "Forecastfox";
  40. const NAME           = "forecastfox";
  41. const KEY            = "/weather/" + NAME;
  42. const VERSION        = "0.8.5.1";
  43. const LOCALE_LIST    = ["en-US", "ca-AD", "da-DK", "de-DE", "el-GR", "es-ES", "eu-ES", "fr-FR", "fy-NL", "hu-HU", "it-IT", "ja-JP", 
  44.                         "lv-LV", "mn-MN", "nb-NO", "nl-NL", "pl-PL", "pt-BR", "ru-RU", "sk-SK", "sl-SI", 
  45.                         "sr-YU", "sv-SE", "tr-TR", "zh-CN", "zh-TW"];
  46. const JAR_FILE       = NAME + ".jar";
  47. const PREFS_FILE     = "defaults/preferences/" + NAME + ".js";
  48. const AUTOREG_FILE   = "defaults/.autoreg";
  49. const XPCOM_DIREC    = "components/";
  50. const XPCOM_NAMES_JS = ["nsForecastfox", "ffError", "ffParser", "ffPing", "ffProfiles", "ffDisk", "ffResolver", "ffIconPack", "ffIconManager", "ffWeb"];
  51. const XPCOM_NAMES_XPT = ["nsForecastfox", "ffError", "ffParser", "ffPing", "ffProfiles", "ffDisk", "ffIconPack", "ffIconManager", "ffWeb"];
  52.  
  53. const CONTENT_FOLDER = "content/" + NAME + "/";
  54.  
  55. var err = null;
  56.  
  57. // begin the install
  58. initInstall(NAME, KEY, VERSION);
  59.   
  60. var mainDir = getFolder("Profile", "extensions/" + "{0538E3E3-7E9B-4d49-8831-A227C80A7AD3}");
  61. var chromeDir = getFolder(mainDir, "chrome");
  62.  
  63. addFile(KEY, VERSION, "chrome/"+JAR_FILE, chromeDir, null);
  64.  
  65. // Add the defaults folder
  66. var defaultDir = getFolder(mainDir, "defaults");
  67. addDirectory(KEY, VERSION, "defaults", defaultDir, null);
  68. defaultDir = getFolder(getFolder("Program", "defaults"),"pref");
  69. addFile(KEY, VERSION, PREFS_FILE, defaultDir, null);
  70.  
  71. //hack to make sure we register the component
  72. var pgmDir = getFolder("Program");
  73. addFile(KEY, VERSION, AUTOREG_FILE, pgmDir, null);
  74.  
  75. // Register the chrome URLs
  76. registerChrome(CONTENT | PROFILE_CHROME | DELAYED_CHROME, getFolder(chromeDir, JAR_FILE), "content/"+NAME+"/");
  77. registerChrome(SKIN | PROFILE_CHROME | DELAYED_CHROME, getFolder(chromeDir, JAR_FILE), "skin/classic/"+NAME+"/");
  78.  
  79. for (var x = 0; x < LOCALE_LIST.length; x++)
  80.   registerChrome(LOCALE | PROFILE_CHROME | DELAYED_CHROME, getFolder(chromeDir, JAR_FILE), "locale/"+LOCALE_LIST[x]+"/"+NAME+"/");
  81.  
  82. var compDir = getFolder("Components");
  83. for (x = 0; x < XPCOM_NAMES_JS.length; x++)
  84.   addFile(KEY, VERSION, XPCOM_DIREC+XPCOM_NAMES_JS[x]+".js", compDir, null);
  85. for (x = 0; x < XPCOM_NAMES_XPT.length; x++)
  86.   addFile(KEY, VERSION, XPCOM_DIREC+XPCOM_NAMES_XPT[x]+".xpt", compDir, null);
  87.  
  88.  
  89. // Now install..
  90. if (getLastError() == SUCCESS) {
  91.   err = performInstall();
  92.   if ((err == SUCCESS) || (err == 999))
  93.     alert(DISPLAY_NAME + " " + VERSION + " has been installed successfully!\nPlease restart to enable the extension.");
  94. }
  95. else
  96.   cancelInstall();
  97.